package com.prs.crm.action.oa.schedule;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Locale;


import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.annotation.Clew;
import com.prs.crm.domain.hr.Dept;
import com.prs.crm.domain.hr.Resume;
import com.prs.crm.domain.oa.schedule.CommonSchedule;
import com.prs.crm.domain.oa.schedule.CycleSchedule;
import com.prs.crm.domain.oa.schedule.MyThings;
import com.prs.crm.domain.oa.schedule.OthersThings;
import com.prs.crm.domain.warning.TaskRemind;
import com.prs.crm.service.hr.DeptService;
import com.prs.crm.service.hr.ResumeService;

import com.prs.crm.service.oa.schedule.CommonScheduleService;
import com.prs.crm.service.oa.schedule.CycleScheduleService;
import com.prs.crm.service.oa.schedule.OthersThingsService;
import com.prs.crm.service.warning.TaskRemindService;
import com.prs.crm.tools.Datetools;

public class OthersThingsAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private OthersThings othersThings;
	private OthersThingsService othersThingsService;
	
	private PaginationSupport pagination;
	
	private Integer[]  ids;
	
	private Collection<Dept> dept;
	private DeptService deptService;
	
	
	private Collection<Resume> resume;
	private ResumeService resumeService;
	
	
	private String ot_state;
	private CycleSchedule cycleSchedule;
	private CommonSchedule commonSchedule;
	private CycleScheduleService cycleScheduleService; 
	private CommonScheduleService commonScheduleService;
	private TaskRemindService taskRemindService;
	public TaskRemindService getTaskRemindService() {
		return taskRemindService;
	}

	public void setTaskRemindService(TaskRemindService taskRemindService) {
		this.taskRemindService = taskRemindService;
	}

	public CycleScheduleService getCycleScheduleService() {
		return cycleScheduleService;
	}

	public void setCycleScheduleService(CycleScheduleService cycleScheduleService) {
		this.cycleScheduleService = cycleScheduleService;
	}

	public CommonScheduleService getCommonScheduleService() {
		return commonScheduleService;
	}

	public void setCommonScheduleService(CommonScheduleService commonScheduleService) {
		this.commonScheduleService = commonScheduleService;
	}

	public CommonSchedule getCommonSchedule() {
		return commonSchedule;
	}

	public void setCommonSchedule(CommonSchedule commonSchedule) {
		this.commonSchedule = commonSchedule;
	}

	public CycleSchedule getCycleSchedule() {
		return cycleSchedule;
	}

	public void setCycleSchedule(CycleSchedule cycleSchedule) {
		this.cycleSchedule = cycleSchedule;
	}

	public String getOt_state() {
		return ot_state;
	}

	public void setOt_state(String otState) {
		ot_state = otState;
	}
	public Collection<Resume> getResume() {
		return resume;
	}

	public void setResume(Collection<Resume> resume) {
		this.resume = resume;
	}

	public ResumeService getResumeService() {
		return resumeService;
	}

	public void setResumeService(ResumeService resumeService) {
		this.resumeService = resumeService;
	}

	public Collection<Dept> getDept() {
		return dept;
	}

	public void setDept(Collection<Dept> dept) {
		this.dept = dept;
	}

	public DeptService getDeptService() {
		return deptService;
	}

	public void setDeptService(DeptService deptService) {
		this.deptService = deptService;
	}

	public OthersThings getOthersThings() {
		return othersThings;
	}

	public void setOthersThings(OthersThings othersThings) {
		this.othersThings = othersThings;
	}

	public OthersThingsService getOthersThingsService() {
		return othersThingsService;
	}

	public void setOthersThingsService(OthersThingsService othersThingsService) {
		this.othersThingsService = othersThingsService;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public Integer[] getIds() {
		return ids;
	}

	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	

	@Action("listOthersThings")
	public String listOthersThings(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(OthersThings.class).add(Restrictions.eq("ot_type", "普通日程"));
		if (othersThings!=null) {
			criteria.add(Restrictions.eq("receivePerson", othersThings.getReceivePerson()));
		}
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOthersThingsService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
	@Action("findOthersThings")
	public String findOthersThings(){
		return SUCCESS;
	}
	@Action("listCycleOthersThings")
	public String listCycleOthersThings() throws ParseException{
		List<OthersThings> mh=this.getOthersThingsService().getAllOthersThings();
		for (OthersThings mt : mh) {
			if ("按天".equals(mt.getJiange())) {
				Date da=new Date();
				String starttime=mt.getStartTime();
				String num=mt.getDateTime();
				Integer nums=Integer.parseInt(num);
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(starttime);
				String time=sf.format(new Date(dat.getTime()+nums*24*60*60*1000));
				Date dat1=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(time);
				Date dat2=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(sf.format(da));
				if (dat1.equals(dat2)) {
					OthersThings mth=this.getOthersThingsService().getTime(time);
					if (mth==null) {
						mth=new OthersThings();
						mth.setOt_type(mt.getOt_type());
						mth.setJiange(mt.getJiange());
						mth.setDateTime(mt.getDateTime());
						mth.setCycleStratTime(mt.getCycleStratTime());
						mth.setShichang(mt.getShichang());
						mth.setOt_thingsContext(mt.getOt_thingsContext());
						mth.setOt_importance(mt.getOt_importance());
						mth.setSendInfo(mt.getSendInfo());
						mth.setSendShouji(mt.getSendShouji());
						mth.setSendEmail(mt.getSendEmail());
						mth.setStartWarn(mt.getStartWarn());
						mth.setOutWarn(mt.getOutWarn());
						mth.setOverWarn(mt.getOverWarn());
						mth.setOt_state("未完成");
						this.getOthersThingsService().save(mth);
					}
				}
			}else if("按月".equals(mt.getJiange())){
				Date da=new Date();
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(mt.getStartTime());
				Calendar ca1=Calendar.getInstance();
				ca1.setTime(dat);
				ca1.add(Calendar.MONTH, 1);
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
				Date dat1=ca1.getTime();
				Date dat2=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(sf.format(da));
				if (dat1.equals(dat2) || dat2.after(dat1)) {
					OthersThings mth=this.getOthersThingsService().getTime(sf.format(dat1));
					if (mth==null) {
						mth=new OthersThings();
						mth.setOt_type(mt.getOt_type());
						mth.setJiange(mt.getJiange());
						mth.setMonthTime(mt.getMonthTime());
						mth.setCycleStratTime(mt.getCycleStratTime());
						mth.setShichang(mt.getShichang());
						mth.setOt_thingsContext(mt.getOt_thingsContext());
						mth.setOt_importance(mt.getOt_importance());
						mth.setSendInfo(mt.getSendInfo());
						mth.setSendShouji(mt.getSendShouji());
						mth.setSendEmail(mt.getSendEmail());
						mth.setStartWarn(mt.getStartWarn());
						mth.setOutWarn(mt.getOutWarn());
						mth.setOverWarn(mt.getOverWarn());
						mth.setStartTime(sf.format(dat1));
						mth.setOt_state("未完成");
						this.getOthersThingsService().save(mth);
					}

				}
			}else if("按周".equals(mt.getJiange())){
				Date da=new Date();
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(mt.getStartTime());
				Calendar ca1=Calendar.getInstance();
				ca1.setTime(dat);
				ca1.add(Calendar.DAY_OF_WEEK, 7);
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
				Date dat1=ca1.getTime();
				Date dat2=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(sf.format(da));
				if (dat1.equals(dat2) || dat2.after(dat1)) {
					OthersThings mth=this.getOthersThingsService().getTime(sf.format(dat1));
					if (mth==null) {
						mth=new OthersThings();
						mth.setOt_type(mt.getOt_type());
						mth.setJiange(mt.getJiange());
						mth.setCycleTime(mt.getCycleTime());
						mth.setCycleStratTime(mt.getCycleStratTime());
						mth.setShichang(mt.getShichang());
						mth.setOt_thingsContext(mt.getOt_thingsContext());
						mth.setOt_importance(mt.getOt_importance());
						mth.setSendInfo(mt.getSendInfo());
						mth.setSendShouji(mt.getSendShouji());
						mth.setSendEmail(mt.getSendEmail());
						mth.setStartWarn(mt.getStartWarn());
						mth.setOutWarn(mt.getOutWarn());
						mth.setOverWarn(mt.getOverWarn());
						mth.setStartTime(sf.format(dat1));
						mth.setOt_state("未完成");
						this.getOthersThingsService().save(mth);
					}
				}
			}
		}
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(OthersThings.class).add(Restrictions.eq("ot_type", "周期性日程"));
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOthersThingsService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
//	@Action("editOthersThings")
//	public String edit(){
//		if (othersThings!=null) {
//			if (othersThings.getOt_state().equals("未完成")) {
//				this.addActionError("该事务正在进行中！");
//				return ERROR;
//			}
//		}
//		return SUCCESS;
//	}
	
	@Action("editCycleOthersThings")
	public String editCycleOthersThings() throws ParseException{
		if (othersThings!=null) {
			if ("未完成".equals(othersThings.getOt_state())) {		
				Date date=new Date();
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(othersThings.getStartTime());
				if (date.after(dat)) {
					this.addActionError("该日程正在进行中");
					return ERROR;
				}else{
					this.addActionError("该日程尚未进行");
					return ERROR;
				}
			}else{
				this.addActionError("该日程已经完成");
				return ERROR;
			}
		}
		return SUCCESS;
	}
	
	@Action(value = "saveOthersThings", results = {
			@Result(name = "success", type = "redirect", location = "listOthersThings"),
			@Result(name = "error", type = "chain", location = "editOthersThings")
			})
	public String saveOthersThings() throws ParseException{
		if(othersThings.getOt_type()==null){
			this.addActionError("请选择日程类型！");
			return ERROR;
		}
		if(othersThings.getCs_beginTime()==null){
			othersThings.setCs_beginTime(new Date());
		}
		if(othersThings.getCs_overTime()==null){
			othersThings.setCs_overTime(new Date());
		}
		othersThings.setOt_state("未完成");
		this.getOthersThingsService().saveOthersThings(othersThings);
		if ("按月".equals(othersThings.getJiange())) {
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM");
			String date=sf.format(dt);
			String day=othersThings.getMonthTime();
			String time=othersThings.getCycleStratTime();
			Integer day1=Integer.parseInt(day);
			if (day1>0 && day1<10) {
				othersThings.setStartTime(date+"-"+"0"+day+" "+time);
			}else{
				othersThings.setStartTime(date+"-"+day+" "+time);
			}
		}else if("按周".equals(othersThings.getJiange())){
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd",Locale.CHINA);
			Calendar cd=Calendar.getInstance(Locale.CHINA);
			if("星期一".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
			}else if("星期二".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
			}else if("星期三".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
			}else if("星期四".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
			}else if("星期五".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
			}else if("星期六".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
			}else if("星期日".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
			}
			String time=othersThings.getCycleStratTime();
			othersThings.setStartTime(sf.format(cd.getTime())+" "+time);
		}else if("按天".equals(othersThings.getJiange())){
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
			String dat=sf.format(dt);
			String time=othersThings.getCycleStratTime();
			othersThings.setStartTime(dat+" "+time);
		}
		this.getOthersThingsService().submit(othersThings);
		Datetools  dt=new Datetools();
		Date startTime=othersThings.getCs_beginTime();
		Date endTime=othersThings.getCs_overTime();
		Date startTime1=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(othersThings.getStartTime());
		if(othersThings.getSendInfo()){
			if (othersThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
			if (othersThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
			if (othersThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
		}
		if (othersThings.getSendEmail()) {
			if (othersThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
			if (othersThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
			if (othersThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
		}
		if (othersThings.getSendShouji()) {
			if (othersThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
			if (othersThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
			if (othersThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+othersThings.getOt_thingsContext()+"即将开始");
				t1.setReId(String.valueOf(othersThings.getReceivePerson().getId()));
				t1.setRestyle("我的日程");
				if ("普通日程".equals(othersThings.getOt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
		}
		return SUCCESS;
	}
	@Action(value = "saveOthersThings1", results = {
			@Result(name = "success", type = "redirect", location = "listCycleOthersThings"),
			@Result(name = "error", type = "chain", location = "editCycleOthersThings")
			})
	public String saveOthersThings1(){
		if(othersThings.getOt_type()==null){
			this.addActionError("请选择日程类型！");
			return ERROR;
		}
		if(othersThings.getCs_beginTime()==null){
			othersThings.setCs_beginTime(new Date());
		}
		if(othersThings.getCs_overTime()==null){
			othersThings.setCs_overTime(new Date());
		}
		othersThings.setOt_state("未完成");
		this.getOthersThingsService().saveOthersThings(othersThings);
		if ("按月".equals(othersThings.getJiange())) {
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM");
			String date=sf.format(dt);
			String day=othersThings.getMonthTime();
			String time=othersThings.getCycleStratTime();
			Integer day1=Integer.parseInt(day);
			if (day1>0 && day1<10) {
				othersThings.setStartTime(date+"-"+"0"+day+" "+time);
			}else{
				othersThings.setStartTime(date+"-"+day+" "+time);
			}
		}else if("按周".equals(othersThings.getJiange())){
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd",Locale.CHINA);
			Calendar cd=Calendar.getInstance(Locale.CHINA);
			if("星期一".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
			}else if("星期二".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
			}else if("星期三".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
			}else if("星期四".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
			}else if("星期五".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
			}else if("星期六".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
			}else if("星期日".equals(othersThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
			}
			String time=othersThings.getCycleStratTime();
			othersThings.setStartTime(sf.format(cd.getTime())+" "+time);
		}else if("按天".equals(othersThings.getJiange())){
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
			String dat=sf.format(dt);
			String time=othersThings.getCycleStratTime();
			othersThings.setStartTime(dat+" "+time);
		}
		this.getOthersThingsService().submit(othersThings);
		return SUCCESS;
	}
	@Action(value = "removeOthersThings", results = {
			@Result(name = "success", type = "redirect", location = "listCycleOthersThings"),
			@Result(name = "error", type = "chain", location = "listCycleOthersThings")
			})
	public String removeOthersThings(){
		if (ids==null) {
			this.addActionError("请选择一行进行操作！");
			return ERROR;
		}
		this.getOthersThingsService().batchRemove(ids);
		return SUCCESS;
	}
	@Action(value = "queryOtherThings", results = {
			@Result(name = "success", type = "redirect", location = "listOthersThings?othersThings.receivePerson=${othersThings.getReceivePerson().getId()}"),
			@Result(name = "error", type = "chain", location = "findOthersThings")
			})
	public String queryOtherThings(){
		if (othersThings.getReceivePerson()==null) {
			this.addActionError("请选择要查看的人");
			return ERROR;
		}
		System.out.println(othersThings.getReceivePerson().getId());
		this.getOthersThingsService().findOtherThings(othersThings.getReceivePerson().getId());
		return SUCCESS;
	}
	
	@Action(value = "saveFinishOthers", results = {
			@Result(name = "success", type = "redirect", location = "listOthersThings?othersThings.receivePerson=${othersThings.getReceivePerson().getId()}"),
			@Result(name = "error", type = "chain", location = "editOthersThings")
			})
	public String saveFinishOthers(){
		othersThings.setOt_state("完成");
		this.getOthersThingsService().submit(othersThings);
		return SUCCESS;
	}
	@Action(value = "saveFinishOthers1", results = {
			@Result(name = "success", type = "redirect", location = "listCycleOthersThings"),
			@Result(name = "error", type = "chain", location = "editCycleOthersThings")
			})
	public String saveFinishOthers1(){
		othersThings.setOt_state("完成");
		this.getOthersThingsService().submit(othersThings);
		return SUCCESS;
	}
	@Action(value = "removeOthersThing", results = {
			@Result(name = "success", type = "redirect", location = "listOthersThings?othersThings.receivePerson=${othersThings.getReceivePerson().getId()}"),
			@Result(name = "error", type = "chain", location = "editOthersThings")
			})
	public String removeOthersThing(){
		this.getOthersThingsService().remove(othersThings);
		return SUCCESS;
	}
	@Action(value = "removeOthersThing1", results = {
			@Result(name = "success", type = "redirect", location = "listCycleOthersThings"),
			@Result(name = "error", type = "chain", location = "editCycleOthersThings")
			})
	public String removeOthersThing1(){
		this.getOthersThingsService().remove(othersThings);
		return SUCCESS;
	}
}
